<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>修改密码</title>
<meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="format-detection" content="telephone=no" />
<link type="text/css" rel="stylesheet" href="assets/css/bootstrap.min.css">
<link type="text/css" rel="stylesheet" href="assets/css/style.css">
</head>

<body class="Spage_body">
<!-- top-head -->
<div class="top_head">
	修改密码
	<a href="javascript:void(0)" class="top_head_back" onClick="javascript:history.back(-1);"><img src="assets/images/back_btn.png"></a>
</div>
<!-- top-head -->
<!-- wrap -->
<!-- login_box -->
<div class="container login_box" style="padding:15px 2%;">
	<form>
		<div class="login_input">
        	<div class="login_input_d1">
            	<p class="col-xs-3 col-sm-2 login_input_d1_p1">用户名</p>
                <p class="col-xs-9 col-sm-10 login_input_d1_p2">
                	<input type="text" name="name" id="name" readonly placeholder="请输入用户名">
                </p>
            </div>
            <div class="login_input_d1">
            	<p class="col-xs-3 col-sm-2 login_input_d1_p1">新的密码</p>
                <p class="col-xs-9 col-sm-10 login_input_d1_p2">
                	<input type="password" name="password" id="password" placeholder="6-18位的数字和字母混合">
                </p>
            </div>
            <div class="login_input_d1">
            	<p class="col-xs-3 col-sm-2 login_input_d2_p1">确认密码</p>
                <p class="col-xs-9 col-sm-10 login_input_d2_p2">
                	<input type="password" id="Cpassword" placeholder="请再输入一次密码">
                </p>
            </div>
        </div>
        <div class="login_btn col-xs-12">
        	<input id="change" type="button" value="修改">
        </div>
    </form>
</div>
<!-- login_box -->
<!-- wrap -->
<script type="text/javascript" src="assets/scripts/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="assets/scripts/hr-jquery.js"></script>
<script>
	$(document).ready(function(){
		$("#change").click(function(){
			var $password = $("#password").val();
			var $Cpassword = $("#Cpassword").val();
			if($password != $Cpassword){
				alert("两次密码不一样！")
			}else{
				upDateUser();
			}
		});
		$.get("getUser",function(data){
			$("#name").val(data.name);
		})
		function upDateUser(){
			var $name = $("#name").val();
			var $password = $("#password").val();
			var $dataObjdct = {
					name:$name,
					password:$password,
			}
			
			$.ajax({
				type:"post",
				url:"upDateUser",
				dataType:"json",
				contentType:"application/json;charset=utf-8",
				data:JSON.stringify($dataObjdct),
				success:function(data){
					if(data.res == 1){
						alert("修改成功！");
						window.location.href="center";
					}else{
						alert(data.resMsg);
					}
				}
			})
		}
	});
</script>
</body>
</html>